package chapter6.homework;

abstract class Shape {
    abstract double getArea();
}

class Circle extends Shape {
    private final double radius;


    public Circle(double radius) {

        this.radius = radius;

    }

    @Override
    public double getArea() {

        return 3.14 * radius * radius;

    }

}


class Rectangle extends Shape {

    private final double width;
    private final double height;


    public Rectangle(double width, double height) {

        this.width = width;

        this.height = height;

    }


    public double getArea() {

        return width * height;

    }

}


public class Test {

    public static void main(String[] args) {

        Shape[] shapes = new Shape[2];

        shapes[0] = new Circle(2);

        shapes[1] = new Rectangle(3, 4);


        for (int i = 0; i < shapes.length; i++) {

            System.out.println("第" + i + "个形状的面积是: " + shapes[i].getArea());

        }

    }

}


